<!--<script type="text/javascript" src="__STATIC__/js/jquery.js"></script>-->
<script src="__PUBLIC__/js/global.js"></script>
<script type="text/javascript" src="__STATIC__/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">

function changeUrlArg(url, arg, val){
    var pattern = arg+'=([^&]*)';
    var replaceText = arg+'='+val;
    return url.match(pattern) ? url.replace(eval('/('+ arg+'=)([^&]*)/gi'), replaceText) : (url.match('[\?]') ? url+'&'+replaceText : url+'?'+replaceText);
}


// var is_distribut = getCookie('is_distribut'); // 是否分销代理
//var user_id = getCookie('user_id'); // 当前用户id
  var user_id = {$_SESSION['user']['user_id']};
//alert(is_distribut+'=='+user_id);

// 如果已经登录了, 并且是分销商
// if(parseInt(is_distribut) == 1 && parseInt(user_id) > 0)
// {									
// 	ShareLink = ShareLink + "&first_leader="+user_id;									
// }										
var title = "封坛天下";
var desc = "封坛天下——您的个性化专属酒柜";


var url = window.location.href;
var ShareLink = "";
if(url.indexOf("?") >=0){
	if(url.indexOf("distribut_id") > 0){
		ShareLink = changeUrlArg(url,"distribut_id",user_id);
	}else{
		ShareLink = url + "&distribut_id=" +user_id;
	}
	
}
else{
	 ShareLink = url + "?distribut_id=" +user_id;
}
var ShareImgUrl = "http://{$_SERVER[HTTP_HOST]}/public/images/fenxiang.jpg"; // 分享图标
<if condition="CONTROLLER_NAME eq 'Station'">
	<if !empty($station_info.name)>
	var title1 = "{$station_info.name}诚邀您加入";
	<else>
	var title1 = "封坛天下诚邀您创建您的品酒俱乐部！";
	</if>
	var desc1 = "封坛天下——品天下美酒，藏纯粮原浆！";
	var ShareLink = "http://{$_SERVER[HTTP_HOST]}/Mobile/station/station_info/station_id/{$station_info.id}.html";
    var ShareImgUrl1 =  ShareImgUrl; 
<else>    
    <if condition="ACTION_NAME eq 'goodsInfo'"> //商品，一元夺宝 显示商品图标,平台名称,模块
		var ShareImgUrl1 = "http://{$_SERVER[HTTP_HOST]}{$goods[goods_id]|goods_thum_images=400,400}"; // 分享图标
		var title1 = "封坛天下";
		<if condition="CONTROLLER_NAME eq 'Goods'">
		var desc1 = "原产地特产:{$goods.goods_name}";
		<elseif condition="CONTROLLER_NAME eq 'Cellar'">
		var desc1 = "封坛窖藏:{$goods.goods_name}";
		<else />
		var desc1 = "个性定制:{$goods.goods_name}";
		</if>
	<elseif condition="ACTION_NAME eq 'index'">
		var ShareImgUrl1 = ShareImgUrl; // 分享图标
		var title1 = "封坛天下";
		<if condition="CONTROLLER_NAME eq 'Destine'">
		var desc1 = "个性定制:彰显您的尊贵与个性！";
		<elseif condition="CONTROLLER_NAME eq 'Cellar'">
		var desc1 = "封坛藏酒:封坛纯粮美酒，珍藏多彩人生！";
		<elseif condition="CONTROLLER_NAME eq 'Index'">
		var desc1 = "原产地特产:绿色康饮，从原产地食品开始！";
		<else />
		var desc1 = desc;
		</if>
	<elseif condition="ACTION_NAME eq 'indianaInfo'">
		var title1 = "封坛天下";
		var desc1 = "一元夺宝:{$goods.goods_name}";
		var ShareImgUrl1 = "http://{$_SERVER[HTTP_HOST]}{$goods[goods_id]|goods_thum_images=400,400}"; // 分享图标
	<elseif condition="ACTION_NAME eq 'distribut_qr'">
		var title1 = "封坛天下";
		var desc1 = "封坛天下——您的个性化专属酒柜！";
		var ShareImgUrl1 = "http://{$_SERVER[HTTP_HOST]}{$imgurl|substr=1}"; // 分享图标
	<elseif condition="ACTION_NAME eq 'article'">
		var title1 = "封坛天下";
		var desc1 = "{$article.title}";
		var ShareImgUrl1 =  ShareImgUrl; // 分享图标;
	<elseif condition="ACTION_NAME eq 'dial'">
		var title1 = "封坛天下";
		var desc1 = "大转盘幸运抽奖得红包,银酒币即可参与";
		var ShareImgUrl1 =  "http://{$_SERVER[HTTP_HOST]}/public/images/dial/dazhuanp.png"; // 转盘图标;
	<elseif condition="ACTION_NAME eq 'dial_record'">
		var title1 = "封坛天下";
		var desc1 = "大转盘幸运抽奖得红包,银酒币即可参与";
		var ShareImgUrl1 =  "http://{$_SERVER[HTTP_HOST]}/public/images/dial/dazhuanp.png"; // 转盘图标;
	<elseif condition="ACTION_NAME eq 'exchange_list'">
		var title1 = "封坛天下";
		var desc1 = "商品兑换专区,银酒币即可参与兑换";
		var ShareImgUrl1 =  "http://{$_SERVER[HTTP_HOST]}/template/mobile/new/static/images/duihuan02.png"; // 兑换商品列表页图标;
	<elseif condition="ACTION_NAME eq 'exchange_info'">
		var title1 = "封坛天下";
		var desc1 = "{$exchange_info.goods_name}-(兑换专区)";
		var ShareImgUrl1 =  "http://{$_SERVER[HTTP_HOST]}{$exchange_info.original_img}"; // 兑换商品列表页图标;
	<else />
		var title1 = title;
		var desc1 = desc;
		var ShareImgUrl1 = ShareImgUrl; // 分享图标
	</if>
</if>

//文章 
var ShareLink3 = 'http://mp.weixin.qq.com/s?__biz=MzIwNzU2NjAzMg==&mid=2247483667&idx=1&sn=dee4d01774b277beec311e68057d669e&chksm=971124aca066adba83518cd7a00aafcf751eb0684dfa713317df059104cefc0c64baa6b50533&mpshare=1&scene=23&srcid=0523SXwKNDyhFidTbxm1a3VF#rd';
// 微信配置
wx.config({
    debug: false, 
    appId: "{$signPackage['appId']}", 
    timestamp: '{$signPackage["timestamp"]}', 
    nonceStr: '{$signPackage["nonceStr"]}', 
    signature: '{$signPackage["signature"]}',
    jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage','onMenuShareQQ','onMenuShareQZone','hideOptionMenu'] // 功能列表，我们要使用JS-SDK的什么功能
});

// config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，config是一个客户端的异步操作，所以如果需要在 页面加载时就调用相关接口，则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口，则可以直接调用，不需要放在ready 函数中。
wx.ready(function(){
    // 获取"分享到朋友圈"按钮点击状态及自定义分享内容接口
    wx.onMenuShareTimeline({
        'title':"【"+title1+"】"+desc1, // 分享标题
        'link':ShareLink,
        'imgUrl':ShareImgUrl1, // 分享图标
        success: function () { 
//         	share_income(user_id,1);
        },
    });

    // 获取"分享给朋友"按钮点击状态及自定义分享内容接口
    wx.onMenuShareAppMessage({
        title:title1, // 分享标题
        desc: desc1, // 分享描述
        link:ShareLink,
        imgUrl:ShareImgUrl1, // 分享图标
//         imgUrl:imgUrl:ShareImgUrl, // 分享图标
        success: function () { 
//         	share_income(user_id,2);
        },
    });
	// 分享到QQ
	wx.onMenuShareQQ({
        title:title1, // 分享标题
        desc:desc1, // 分享描述
        link:ShareLink3,
        imgUrl:ShareImgUrl1, // 分享图标
        success: function () { 
//         	share_income(user_id,3);
        },
	});	
	// 分享到QQ空间
	wx.onMenuShareQZone({
        title:title1, // 分享标题
        desc:desc1, // 分享描述
        link:ShareLink3,
        imgUrl:ShareImgUrl1, // 分享图标
        success: function () { 
//         	share_income(user_id,4);
        },
	});

//    <if condition="CONTROLLER_NAME eq 'User'"> 
// 	wx.hideOptionMenu();  // 用户中心 隐藏微信菜单
//    </if>
	
});

// function share_income(user_id,type){
// 	if(user_id > 0){
// 		$.ajax({
// 			type:"POST",
// 			url:"/Mobile/User/fenxiang_income",
// 			data:{"user_id":user_id,'type':type},
// 			dataType:"json",
// 			async:false,//同步操作
// 			success:function(date){
// 				alert(date.msg);
// 			}
// 		});
// 	}
// }

</script>


<!-- <!--微信关注提醒 start  -->
<button class="guide" onclick="follow_wx()" >关注公众号</button>
<style type="text/css">
  .guide{width:20px;height:100px;display:none;text-align: center;border-radius: 8px ;font-size:12px;padding:8px 0;border:1px solid #adadab;color:#000000;background-color: #fff;position: fixed;right: 6px;bottom: 200px;} 
  #cover{display:none;position:absolute;left:0;top:0;z-index:18888;background-color:#000000;opacity:0.7;}  
  #guide{display:none;position:absolute;top:5px;z-index:19999;}  
  #guide img{width: 70%;height: auto;display: block;margin: 0 auto;margin-top: 10px;} 
  .ewm_tc{width:100%;padding: 0.5em;display: none;}
  .ewm_tc p:first-child{line-height: 2em;text-align: center;color: #333;}
  .ewm_tc p:nth-child(2){line-height: 2em;text-align: center;}
  .ewm_tc p:nth-child(3){text-align: center;padding-top: 1em;}
  .ewm_tc p:nth-child(3) img{width:70%;display: initial;}
  .ewm_tc p:nth-child(4){line-height: 1.6em;padding-top: 1em;text-align: center;padding-bottom: 0.5em;}
</style>
<!--只针对微信浏览器-->
<if strstr($_SERVER['HTTP_USER_AGENT'],'MicroMessenger')>
<div class="ewm_tc">
	<p class="fs_l">亲，关注公众号有更多惊喜哦！</p>
	<p class="fs_xs">(打开微信识别下方二维码即可)</p>
	<p><img src="{$wechat_config['qr']}" /></p>
	<p class="fs_xs">为了方便你更快的找到我们，敬请关注我们的微信公众平台，美酒好茶等你来领！</p>
</div>
<script type="text/javascript">

    var is_follow = <?php $is_f = empty($_SESSION['user']['is_follow'])?0:1; echo $is_f; ?>;
//  if(is_follow==0){
//		layer.open({
//			type : 1,
//			area:"85%",
//			title: false,
//			shadeClose:true,
//			content: $('.ewm_tc')
//		});
//	}     
</script> 
<!--微信关注提醒  end-->
</if>
<!-- <if $is_red_packet===0> -->
<!-- 	<div class="hb_bg" style="position: fixed;width:100%;height:100%;background:rgba(0,0,0,0.3);left: 0;top: 0;z-index: 999;"> -->
<!-- 		<div class="hb_msg fs_xl" style="width:70%;height: 12em;background: #fff;position: absolute;top: 30%;left: 15%;border-radius: 0.5em;"> -->
<!-- 			<div class="hb_t fs_xl" style="width: 100%;height: 7em;background: #D8432B;border-top-left-radius: 0.5em;border-top-right-radius: 0.5em;"> -->
<!-- 				<p style="width:100%;margin: 0 auto;text-align: center;"><img style="display: initial;text-align: center;width:30%;margin-top: 1em;" src="__STATIC__/images/db_105.png" /></p> -->
<!-- 				<p class="fs_m" style="color: #fff;padding: 0 0.5em;line-height: 2em;text-align: center;">你有一个现金红包还未领取哦!</p> -->
<!-- 			</div> -->
<!-- 			<div class="hb_lq" style="width:100%;padding:1.4em 0;"> -->
<!-- 				<a class="fs_m" href="{:U('/Mobile/User/red_packet')}" style="width: 42%;background: #D8432B;margin-left: 5%;color: #fff;display: inline-block;text-align: center;height: 2.4em;line-height: 2.4em;border-radius: 5px;">马上抢</a> -->
<!-- 				<a href="javascript:;" class="bqhb fs_m" style="width: 42%;background: #D0CDCC;color: #fff;margin-left: 5%;display: inline-block;text-align: center;height: 2.4em;line-height: 2.4em;border-radius: 5px;">不抢，我是土豪</a> -->
<!-- 			</div> -->
<!-- 		</div> -->
<!-- 	</div> -->
<!-- </if> -->
<!-- <script> -->
<!-- // 	$(function(){ -->
<!-- // 		$(".bqhb").click(function(){ -->
<!-- // 			$(".hb_bg").hide(); -->
<!-- // 		}); -->
<!-- // 	}) -->
	
<!-- </script> -->
